#ifndef __CMD__man__HEADER_FILE__
#define __CMD__man__HEADER_FILE__

#include "man.h"

///Command interface class to \a man class
///@note this pointer is actually a pointer to the \a man object, this class is just an interface
struct man::cmd_man
{
	void change_direction( uchar d )
	{
		dynarray<uchar>& fcb = ((rsp_base*)this)->fcb();
		uchar* p=fcb.add(1+sizeof(d));
		DASSERT( d>=0 && d<8 );
		*p++ = 0 + d;

		{ *(uchar*)p = d;		p += sizeof(d); }
	}

	void action( uchar d )
	{
		dynarray<uchar>& fcb = ((rsp_base*)this)->fcb();
		uchar* p=fcb.add(1+sizeof(d));
		DASSERT( d>=8 && d<12 );
		*p++ = 8 + d;

		{ *(uchar*)p = d;		p += sizeof(d); }
	}

	void set_colors( uint32 colpri, uint32 colsec, const token& nick )
	{
		dynarray<uchar>& fcb = ((rsp_base*)this)->fcb();
		uchar* p=fcb.add(1+sizeof(colpri)+sizeof(colsec)+(1+nick.len()));
		*p++ = 12;

		{ *(uint32*)p = colpri;		p += sizeof(colpri); }
		{ *(uint32*)p = colsec;		p += sizeof(colsec); }
		{ uint s = nick.len();  DASSERT(s<256);
		*p = s;
		::memcpy( p+1, nick.ptr(), s );
		p += 1+s; }
	}

	void disconnect()
	{
		dynarray<uchar>& fcb = ((rsp_base*)this)->fcb();
		uchar* p=fcb.add(1);
		*p++ = 13;
	}

};

#endif //__CMD__man__HEADER_FILE__
